﻿CREATE PROCEDURE [dbo].[yaf_group_member](
                @BoardID INT,
                @UserID  INT)
AS
    BEGIN
        SELECT   a.GroupID,
                 a.Name,
                 Member = (SELECT COUNT(1)
                           FROM   yaf_UserGroup x
                           WHERE  x.UserID = @UserID
                           AND x.GroupID = a.GroupID)
        FROM     yaf_Group a
        WHERE    a.BoardID = @BoardID
        ORDER BY a.Name
    END


